package com.school.hjt.schoolclasscard.ui

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.view.WindowManager

import com.school.hjt.schoolclasscard.R
import com.school.hjt.schoolclasscard.adapter.LabourAdapter
import com.school.hjt.schoolclasscard.model.LabourActivityModel
import kotlinx.android.synthetic.main.activity_class_labour.*

class LabourActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        supportActionBar!!.hide()
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
        window.setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)
        setContentView(R.layout.activity_class_labour)
        iv_close.setOnClickListener({
            finish()
        })
        val list=ArrayList<String>()
        list.add("")
        list.add("")
        list.add("")
        list.add("")
        list.add("")
        list.add("")
        val model=LabourActivityModel()
        lv_labour.adapter=LabourAdapter(this,model.labours)
        Thread(Runnable {
            while (i > 0) {
                handler.sendEmptyMessage(1)
                if (i <= 0) {
                    break
                }
                try {
                    Thread.sleep(1000)
                } catch (e: InterruptedException) {
                    e.printStackTrace()
                }

                i--
            }
            handler.sendEmptyMessage(2)
        }).start()
    }
    internal var i = 30
    internal var handler: Handler = object : Handler() {
        override fun handleMessage(msg: android.os.Message) {
            if (msg.what == 1) {
                tv_countdown.text = "还剩" + i + "关闭界面"
            } else {
                finish()

            }
        }
    }
}
